package com.price.sample.ui

import android.content.Intent
import android.os.Bundle
import com.price.common.extend.disableNFC
import com.price.common.extend.enableNFC
import com.price.common.extend.getNfcPIN
import com.price.common.extend.isNFCEnabled
import com.price.common.extend.toast
import com.price.common.viewbinding.base.BaseBindingActivity
import com.zp.common.databinding.ActivityNfcBinding

class NFCActivity : BaseBindingActivity<ActivityNfcBinding>() {

    override fun onCreated(savedInstanceState: Bundle?) {
        binding.btnNfc.isSelected=isNFCEnabled()==true
        binding.btnNfc.text=if(isNFCEnabled()==true) "关闭" else "开启"
        binding.btnNfc.setOnClickListener {

            toast("失败")
        }
    }


    override fun onResume() {
        super.onResume()
        enableNFC()
    }

    override fun onPause() {
        super.onPause()
        disableNFC()
    }

    override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)
        val result=intent?.getNfcPIN()
        binding.tvResult.text=result
    }


}